import redis
r = redis.Redis(host='127.0.0.1',port=6379)

ps = r.pubsub()
ps.subscribe('test')  
for item in ps.listen(): 
    if item['type'] == 'message':
        print(item['data'])